package ferp.core.calc;

import ferp.core.game.Game;
import ferp.core.game.Settings;
import ferp.core.player.Player;

/**
 * User: olegs
 * Date: 21/11/11 17:37
 */
public class Leningrad extends Calculator
{
  public Leningrad()
  {
    // initialize Leningrad's costs
    costs[0] = new int[] { 2,  4,  4,  2};
    costs[1] = new int[] { 4,  8,  8,  4};
    costs[2] = new int[] { 6, 12, 12,  6};
    costs[3] = new int[] { 8, 16, 16,  8};
    costs[4] = new int[] {10, 20, 20, 10};
  }

  @Override
  public boolean closed(Game g, Settings settings, Player p)
  {
    return over(g, settings);
  }

  @Override
  public boolean over(Game g, Settings settings)
  {
    int pool = 0;
        
    for (Player p : g.players())
      pool += g.getScore(p.id()).pool.current;
    
    return pool >= settings.poolSize * Game.PLAYERS;
  }

  @Override
  public int getNormalizeFactor()
  {
    return 2;
  }
}
